'use strict';
module.exports = function (sequelize, DataTypes) {

  var Role = sequelize.define('Role', {
    id: {
      type: DataTypes.INTEGER.UNSIGNED,
      primaryKey: true
    },
    roleName: {
      type: DataTypes.STRING(41),
      allowNull: false,
      comment: '角色名称'
    }
  }, {
    classMethods: {
      associate: function (models) {
        Role.hasMany(models.Organization, {
          foreignKey: 'roleId',
          constraints: false
        });
        Role.hasMany(models.Team, {
          foreignKey: 'roleId',
          constraints: false
        });
      }
    },
    timstamps: true,
    paranoid: true,
    tableName: 'roles'
  });

  return Role;
};
